<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Autumn Framework</title>
    <link rel="shortcut icon" href="https://github.com/shuaijunlan/Autumn-Framework/raw/master/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="Lib/layui_v2.2.3/css/layui.css">
    <link rel="stylesheet" href="static/css/login.css">
    <script src="Lib/layui_v2.2.3/layui.js"></script>
</head>
<body>
<div class="layui-carousel video_mask" id="login_carousel" >
    <div carousel-item>
        <div class="carousel_div5"></div>
    </div>
    <div class="login layui-anim layui-anim-up">
        <h1>Autumn CMS</h1></p>
        <form class="layui-form" action="" method="post">
            <div class="layui-form-item">
                <input type="text" name="username" lay-verify="required" placeholder="请输入账号" autocomplete="off"  value="" class="layui-input">
            </div>
            <div class="layui-form-item">
                <input type="password" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off" value="" class="layui-input">
            </div>
            <div class="layui-form-item form_code">
                <input class="layui-input" name="code" placeholder="验证码" lay-verify="required" type="text" autocomplete="off">
                <div class="code"><img src="captcha.do" width="116" height="36"></div>
            </div>

            <button class="layui-btn login_btn" lay-submit="" lay-filter="login">登陆系统</button>
        </form>
        <a style="padding-left: 20%; color: white; line-height: 50px; cursor: help;" href="https://shuaijunlan.cn/autumn-blog/" target="_blank">体验一下Autumn-Blog？</a>

    </div>

</div>

</body>

</html>
<script>
    layui.config({
        base : "static/js/"
    }).use(['form','layer','jquery','common','carousel', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            common = layui.common,
            carousel = layui.carousel;

        /**背景图片轮播*/
        carousel.render({
            elem: '#login_carousel',
            width: '100%',
            height: '100%',
            interval:3000,
            arrow: 'none',
            anim: 'fade',
            indicator:'none'
        });
        layer.open({
            type: 1
            ,title: false //不显示标题栏
            ,closeBtn: false
            ,shade: 0.8
            ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
            ,btn: ['确定']
            ,btnAlign: 'c'
            ,moveType: 1 //拖拽模式，0或者1
            ,content: '<div style="padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
                        '用户名：sys1<br>' +
                        '密&nbsp;&nbsp;&nbsp;码：sys1<br>' +
                        '开源地址：<br>' +
                        '<a href="https://github.com/shuaijunlan/Autumn-Framework" target="_blank" style="color: greenyellow">https://github.com/shuaijunlan/Autumn-Framework(点击跳转)</a></div>'
            ,success: function(layero){

            }
        })

        /**重新生成验证码*/
        function reqCaptcha() {
            var url = "captcha.do?nocache=" + new Date().getTime()
            $('.code img').attr("src",url)
        }
        /**点击验证码重新生成*/
        $('.code img').on('click', function () {
            reqCaptcha();
        });

        /**监听登陆提交*/
        form.on('submit(login)', function (data) {
            //弹出loading
            var loginLoading = top.layer.msg('登陆中，请稍候', {icon: 16, time: false, shade: 0.8});
            //记录ajax请求返回值
            var ajaxReturnData;

            //登陆验证
            $.ajax({
                url: 'loginCheck.do',
                type: 'post',
                async: false,
                data: data.field,
                success: function (data) {
                    ajaxReturnData = data;
                }
            });
            //登陆成功
            if (ajaxReturnData.code == 0000) {
                window.location.href="index.do";
                top.layer.close(loginLoading);
                return false;
            } else {
                top.layer.close(loginLoading);
                common.cmsLayErrorMsg(ajaxReturnData.msg);
                reqCaptcha();
                return false;
            }
        });

    });
</script>